<?php
require_once(__DIR__.'/../core/globalFunctions.php');
require_once(__DIR__.'/../core/eventSubscriber.php');

// This module is reponsible for loading the templates from the style path.
class Style extends EventSubscriber {
	function __construct ($name) {
		// Define events that the module is interested in.
		$this->subscriptions = array("head", "body");
		
		parent::__construct($name);
	}

	function handleEventCallback ($event) {
		// Define responses to event callbacks.
		switch ($event) {
		
			case "head":
			
				echo(file_get_contents(getStylePath() . "/head.html"));
				break;
				
				
			case "body":
			
				$pages = array("home", "feed", "user", "image","gallery","upload","register","login");
				$compare = array_keys($_GET)[0];
				$stylepath = getStylePath();
				if (array_intersect(array_keys($_GET), $pages)) {
					require_once($stylepath . "/" . array_intersect(array_keys($_GET), $pages)[0] . ".php");

				} else {
					require_once($stylepath . "/home.php");
				}
				break;
				
				
		}
	}
}
?>